/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf.bean.client;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import model.client.ReligionBeans;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class ReligionBean_c {
        private int religion_Id;
        private String religion_Name;
        private int religion_Status;

    public int getReligion_Id() {
        return religion_Id;
    }

    public void setReligion_Id(int religion_Id) {
        this.religion_Id = religion_Id;
    }

    public String getReligion_Name() {
        return religion_Name;
    }

    public void setReligion_Name(String religion_Name) {
        this.religion_Name = religion_Name;
    }

    public int getReligion_Status() {
        return religion_Status;
    }

    public void setReligion_Status(int religion_Status) {
        this.religion_Status = religion_Status;
    }
        
        
    /**
     * Creates a new instance of ReligionBean_c
     */
    public ReligionBean_c() {
    }
    
    Connection conn;
        
        public List<ReligionBeans> loadReligion()throws SQLException, ClassNotFoundException{
        conn = JDBCUtil.MyConn.getConnection();
        
        List<ReligionBeans> list = new ArrayList<ReligionBeans>();
        
        String sql ="select * from Religion_Types";
        
        PreparedStatement pst = conn.prepareStatement(sql);
        ResultSet rs = pst.executeQuery();
        while(rs.next()){
            ReligionBeans rb = new ReligionBeans();
            rb.setReligion_Id(rs.getInt("Religion_Type_Id"));
            rb.setReligion_Name(rs.getNString("Religion_Type_Name"));
            list.add(rb);
        }
        return list;
    }
}
